home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3966 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: news.cencom.net!netnews
  2. From: wsenn@cencom.net (Will Senn)
  3. Newsgroups: comp.lang.c++
  4. Subject: cin.get() function challenge
  5. Date: 26 Jan 1996 16:27:40 GMT
  6. Organization: Your Organization
  7. Message-ID: <4eavds$d0u@news.cencom.net>
  8. NNTP-Posting-Host: macomb_ppp__05.cencom.net
  9. Mime-Version: 1.0
  10. Content-Type: Text/Plain; charset=US-ASCII
  11. X-Newsreader: WinVN 0.99.7
  12.  
  13. Alrighty then!
  14.  
  15. Some of you may recall my post of a week ago asking for help on getch() and
  16. cin.  The responses I received were not encouraging.
  17.  
  18. The problem:
  19.     Write a function in C++ not using getch() that will read in ONE 
  20. character at a time, without line buffering.  In other words when the user
  21. presses ONE key, take and process that keypress.  I had originally asked if
  22. it was possible to use cin or another iostream for this purpose.  It would be
  23. nice if someone could definitively address this question.
  24.  
  25. The most common reply I received and one the authors claimed would relieve all
  26. my problems, while implying I should read the BOOK was the following:
  27.  
  28. char temp
  29. cin.get(temp);
  30. switch(temp)
  31. {
  32.     case 'T':
  33.         doSomething();
  34.         break;
  35.     default:
  36.         doSomethingElse();
  37. }
  38.  
  39. This is a piece of code that these 'programmers' obviously read in a BOOK,
  40. it doesn't even come close to addressing my question.  If they had finished
  41. the chapter they were reading they might have noticed that the get() member
  42. function of cin is ALWAYS line buffered!  Another way they might have realized
  43. that their answer was wrong would have been to COMPILE it.
  44.  
  45. If someone out there has a grip on this rather complex issue,  I would very
  46. much appreciate a reply, by mail or post.
  47.  
  48. Thanks,
  49.  
  50. Will
  51.  
  52.